package org.feng.utils;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Author feng
 * @Date 2022/3/17 11:36
 * @Description TODO
 */
@Slf4j
public class ExcelReadListener<T> implements ReadListener<T> {
    /**
     * 数据
     */
    private final List<T> dataList;

    public ExcelReadListener(List<T> dataList) {
        this.dataList = dataList;
    }

    @Override
    public void invoke(T t, AnalysisContext analysisContext) {
        this.dataList.add(t);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        log.info("读取完成");
    }
}
